/*
* @Author: obsidian
* @Date:   2016-02-29 21:25:53
* @Last Modified by:   obsidian
* @Last Modified time: 2016-03-20 10:00:04
*/
#include "gpsteer_driver.h"
#include "gpsteer.h"
#include "module/gps/gps.h"
void TIM2_GPIO_Config(void)
{
        GPIO_InitTypeDef GPIO_Initstructure;

        RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2  , ENABLE);
        RCC_APB2PeriphClockCmd (RCC_APB2Periph_GPIOA |RCC_APB2Periph_GPIOC|RCC_APB2Periph_AFIO, ENABLE );
        GPIO_Initstructure . GPIO_Pin           =GPIO_Pin_2| GPIO_Pin_3 ;
        GPIO_Initstructure .GPIO_Mode           =GPIO_Mode_AF_PP ;
        GPIO_Initstructure .GPIO_Speed          =GPIO_Speed_50MHz;
        GPIO_Init (GPIOA,&GPIO_Initstructure );
}

void TIM2_Mode_Config()
{
        TIM2_GPIO_Config();
        TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
        TIM_OCInitTypeDef  TIM_OCInitStruct;

        TIM_TimeBaseStructure.TIM_Period=30000;
        TIM_TimeBaseStructure.TIM_Prescaler=7;
        TIM_TimeBaseStructure.TIM_ClockDivision=TIM_CKD_DIV1;
        TIM_TimeBaseStructure.TIM_CounterMode=TIM_CounterMode_Up;
        TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);

  
        TIM_OCInitStruct.TIM_OCMode=TIM_OCMode_PWM1;  
        TIM_OCInitStruct.TIM_OutputState=TIM_OutputState_Enable;
		

        TIM_OCInitStruct.TIM_OCPolarity=TIM_OCPolarity_High;
//         TIM_OC4Init(TIM2,&TIM_OCInitStruct);
//         TIM_OC4PreloadConfig(TIM2,TIM_OCPreload_Enable);
         TIM_OC3Init(TIM2,&TIM_OCInitStruct);
         TIM_OC3PreloadConfig(TIM2,TIM_OCPreload_Enable);



        TIM_ARRPreloadConfig (TIM2,ENABLE );
        TIM_CtrlPWMOutputs(TIM2, ENABLE);
        TIM_Cmd(TIM2,ENABLE);
}


